﻿@@master_page.html
<div id="apibox">
    <!--<div class="card">
        <div class="card-header"><h4>登录配置</h4></div>
        <div class="card-body">
            <div class="form-group">
                <div class="p-b-10">
                    账号admin初始化密码是123456 ,如要修改 <a href="/rezero/sys_user.html">点击</a>
                </div>
                <label class="lyear-checkbox">
                    <input type="checkbox" v-model="ReZero.config.Enable" @change="saveLoginConfig">
                    <span class="p-l-5">启用登录</span>
                </label>
            </div>
        </div>
    </div>-->
    <div v-if="licenseConfig.Enable" class="card">
        <div class="card-header"><h4>License 配置</h4></div>
        <div class="card-body">
            <code class="m-tb-10">剩余时间 (单位:天) : {{licenseConfig.ExpirationTime}} </code>
            <input v-model="licenseConfig.License" class="form-control" placeholder="请输入License" />
            <button @click="saveLicenseConfig" class="btn btn-primary m-t-10">保存</button>
        </div>
    </div>
    <div v-if="licenseConfig.HideUi!=true"> 
    <div class="card">
        <div class="card-header"><h4>实体管理配置</h4></div>
        <div class="card-body">
            <div class="form-group">
                <label class="lyear-checkbox">
                    <input type="checkbox" v-model="setting.importUnunderline" @change="saveSetting">
                    <span class="p-l-5">导入实体去掉下划线</span>
                </label>
            </div>
        </div>
    </div>

    <div class="card">
        <div class="card-header"><h4>内部缓存</h4></div>
        <div class="card-body">
            <div class="p-b-10">
                外部修改数据库需要清空 ，缓存内容主要包含：数据库信息、实体信息和接口信息。
            </div>
            <div class="form-group">
                <button type="button" @click="clearInternalCache" class="btn btn-primary">清空</button>
            </div>
        </div>
    </div>
   </div>
</div>
<script>
    var vueObj = new Vue({
        el: '#apibox',
        data: {
            ReZero: {
                config: {
                    Enable: false
                }
            },
            setting: {
                importUnunderline: false
            },
            licenseConfig: {}
        },
        mounted() {
            //this.getLoginConfig();
            this.getSettingItem(1, 1);
            this.getLicenseConfig();
        },
        methods: {
            //getLoginConfig: function () {
            //    axios.get('/PrivateReZeroRoute/100003/getLoginConfig')
            //        .then(response => {
            //            this.ReZero.config.Enable = response.data;
            //        })
            //        .catch(error => {
            //            console.error(error);
            //        });
            //},
            //saveLoginConfig: function () {
            //    var url = "/PrivateReZeroRoute/100003/saveLoginConfig";
            //    axios.post(url, { enable: this.ReZero.config.Enable }, jwHeader)
            //        .then(response => {
            //            tools.alert("登录配置保存成功");
            //            this.error = null;
            //        })
            //        .catch(error => {
            //            this.error = error.message;
            //            this.data = null;
            //        });
            //},
            saveSetting: function () {
                this.saveSettingItem(1, 1, this.setting.importUnunderline);
            },
            getSettingItem: function (typeId, childTypeId) {
                var url = "/PrivateReZeroRoute/100003/GetSetting";
                axios.post(url, { typeId: typeId, childTypeId: childTypeId }, jwHeader)
                    .then(response => {
                        this.setting.importUnunderline = response.data.BoolValue;
                        this.error = null;
                    })
                    .catch(error => {
                        this.error = error.message;
                        this.data = null;
                    });
            },
            saveSettingItem: function (typeId, childTypeId, value) {
                var url = "/PrivateReZeroRoute/100003/UpdateSetting";
                axios.post(url, { typeId: typeId, childTypeId: childTypeId, value: value }, jwHeader)
                    .then(response => {
                        tools.alert("实体管理配置保存成功");
                        this.error = null;
                    })
                    .catch(error => {
                        this.error = error.message;
                        this.data = null;
                    });
            },
            clearInternalCache: function () {
                axios.get("/PrivateReZeroRoute/100003/ClearAllInternalCache", jwHeader)
                    .then(response => {
                        tools.alert("清除成功");
                        this.error = null;
                    })
                    .catch(error => {
                        this.error = error.message;
                        this.data = null;
                    });
            },
            getLicenseConfig() {
                axios.post('/PrivateReZeroRoute/100003/GetLicenseConfig', {}, jwHeader)
                    .then(res => {
                        this.licenseConfig = res.data;
                    });
            },
            saveLicenseConfig() {
                var th = this;
                axios.post('/PrivateReZeroRoute/100003/SaveLicenseConfig', { license: this.licenseConfig.License }, jwHeader)
                    .then(() => {
                        tools.alert('保存成功');
                        window.location.href = window.location.href;
                       }
                    );
            }
        }
    });
</script>










